<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$url = "http://www.ukrcc.com/inc/sertificate_from_edrpo.php";
$post = "SertEdrpo=00703411";
$header = "Content-type:application/octet-stream";
$header.= "host:http://www.ukrcc.com";
$file = "d://123.txt";
$ref = "http://www.ukrcc.com/ua/setificate-one-office/text=3&page=1";

echo 'присвоение значений <br>';

browser($url,$ref,$post,$file);


function browser($url, $ref = false, $post = false, $file = false) {
    $ch = curl_init();
    echo $ch.' начало сесии <br>';

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.63 (Windows NT 5.1; U; ru) Presto/2.1.1");
    curl_setopt($ch, CURLOPT_REFERER, $ref);
    curl_setopt($ch, CURLOPT_POST,1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
    curl_setopt($ch, CURLOPT_VERBOSE,1);
    echo ' процесс пошел <br>';


    file_put_contents($file, '');
        $fp = fopen($file,'w+b');
        curl_setopt($ch, CURLOPT_FILE, $fp);
        curl_exec($ch);
        $html = true;
    
    curl_close($ch);
    return $html;
    echo $html;
}

?>
